b = [1,2,3]

def f2(m):
    print("m：", id(m))
    m.append(4)
# 列表推导式
a = [x for x in range(1, 10) if x % 2 == 0]
print(a)

# 不适用推导式，生成列表。二者对比。体现推导式的优势
b = []
for x in range(1, 10):
    if x % 2 == 0:
        b.append(x)
print(b)

# 字典推导式
# {key_expression: value_expression for 表达式 in 可迭代对象}
values = ["北京", "上海", "深圳", "广州"]
cities = {id * 100: city for id, city in zip(range(1, 5), values)}
print(cities)

my_text = ' i love you, i love sxt, i love gaoqi'
char_count = {c: my_text.count(c) for c in my_text}
print(char_count)

# 集合推导式
# {表达式 for item in 可迭代对象 } 或者：{表达式 for item in 可迭代对象 if 条件判断}

f2(b)
print("b：", id(b))

# m： 2008228745152
# b： 2008228745152